<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" CONTENT="no-cache">
    <meta http-equiv="Pragma" CONTENT="no-cache">
    <meta content="telephone=no" name="format-detection" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <title>金穗服务</title>
    <link rel="stylesheet" href="../../resource/weuimin.css" />
    <link rel="stylesheet" href="../../resource/example.css" />
    <script src="../../resource/jquery1.js"></script>
    <script type="text/javascript" src="../../resource/wapcommon.js"></script>
    <script type="text/javascript" src="../../resource/common.js"></script>
    <script type="text/javascript" src="../../script/api.js"></script>
    <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
    <script type="text/javascript">
        window.apiready = function() {
            $api.fixStatusBar( $api.dom('header') );
            /* 智能调整顶部导航栏 */
            // var header = $api.byId('js-com-header-area');
            if(api.systemType == "ios"){
			   document.getElementById("statusBar").style.background = "#298cb4";
			}
            var header = $api.byId('jsheader');
            if (api.systemType == 'ios') {
                $api.fixIos7Bar(header);
            } else {
                $api.fixStatusBar(header);
            }
        }
    </script>

</head>

<body>
<header id="statusBar">
    <div id="jsheader">
        <nav id="jsnav">
            <a id="jsleft" tapmode="" onclick="api.closeToWin({name: 'root'});">
                <span>主页</span>
            </a>
            <div id="jsmiddle">
                <strong id="jstitle">用户注册</strong>
            </div>
            <a id="jsright">
                <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
            </a>
        </nav>
    </div>
</header>
    <!--BEGIN toast-->
    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content">已完成</p>
        </div>
    </div>
    <!--end toast-->

    <!-- loading toast -->
    <div id="loadingToast" style="display:none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-loading weui-icon_toast"></i>
            <p class="weui-toast__content">数据加载中</p>
        </div>
    </div>
    </div>

    <div class="paddingtop70"></div>
    <div class="com-content">
        <div class="page__bd">
            <div class="weui-cells__title">手动注册</div>
            <div class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <input id="tbx_taxcode" class="weui-input" type="text" placeholder="请输入所在企业税号" />
                    </div>
                </div>
            </div>

            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_default" onclick="manualRegist()">手动注册</a>
            </div>
        </div>

        <div class="page__ft">
            <p><a style="color:#777;font-size:12px" onclick="alert(api.deviceId)">四川航天金穗高技术有限公司</a><b id="bbb"></b></p>
        </div>
    </div>
    <script>
        function manualRegist() {
            var deviceName = api.deviceName;
            var deviceId = api.deviceId;
            var taxcode = $("#tbx_taxcode").val();
            if (taxcode == '') {
                api.alert({
                    title: '手动注册',
                    msg: '请填写企业税号',
                });
            } else {
                $('#loadingToast').fadeIn(100);
                api.ajax({
                    url: 'http://wechat.scjinsui.com/weixin/app/isRegister2.do',
                    method: 'post',
                    data: {
                        values: {
                            openid: deviceId,
                            taxcode: taxcode,
                            deviceName: deviceName
                        }
                    }
                }, function(ret, err) {
                    if (ret) {
                        if (ret.code == 0) {
                            $api.setStorage('userid', ret.userid);
                            $('#loadingToast').hide();
                            $('#toast').fadeIn(100);
                            setTimeout(function() {
                                $('#toast').fadeOut(100);
                            }, 2000);
                        } else if (ret.code == -1) {
                            $('#loadingToast').hide();
                            $api.setStorage('userid', ret.userid);
                            api.alert({
                                msg: '已经注册！'
                            });
                        } else {
                            $('#loadingToast').hide();
                            api.alert({
                                msg: '系统异常...'
                            });
                        }
                    } else {
                        $('#loadingToast').hide();
                        console.log('服务请求错误,请联系管理员');
                    }
                    // setTimeout(function (){$('#loadingToast').fadeOut(100);}, 2000);
                });

            }
        }
    </script>
</body>

</html>
